import { ILoadMapTypeAll } from '@/common';
import { getSelectDataCommon, getTenantID, getLoadMapList } from '@/utils';

// 专家库数据字典
export const loadMdicIds = () => {
  return [
    // `${getTenantID()}${ILoadMapTypeAll.PURCHASE_SUPPLY}`,
    `${getTenantID()}${ILoadMapTypeAll.NEED_CANCEL}`,
    `${getTenantID()}${ILoadMapTypeAll.EXPERTS_LEVEL}`,
    `${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`,
    `${getTenantID()}${ILoadMapTypeAll.PURCHASE_CATEGORY}`,
    `${getTenantID()}${ILoadMapTypeAll.NEED_STATE}`,
    `${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`,
  ];
};

export const NeedDictionaryService = () => {
  const { loadMapInfo: dictionaryData, mapLoading } = getLoadMapList(loadMdicIds());

  // 采购类型
  // const supplyList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_SUPPLY}`], 'name', 'id');

  // 物料类型
  const materialTypeList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`], 'name', 'id');

  // 采购类别
  const supplyKindList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_CATEGORY}`], 'name', 'id');

  // 状态
  const needStateList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.NEED_STATE}`], 'name', 'id');

  // 物料类型
  const materialTypeMapList = dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`];

  // 申请状态
  const checkStateList = [
    {
      value: 1,
      name: '通过',
    },
    {
      value: 2,
      name: '取消',
    },
  ];

  // 采购类别
  const supplyWayList = [
    {
      value: '0',
      name: '月度计划',
    },
    // {
    //   value: '2',
    //   name: '实验平台',
    // },
  ];

  // 取消类型
  const cancelTypeList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.NEED_CANCEL}`], 'name', 'id');

  // 专家级别
  const levelList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.EXPERTS_LEVEL}`], 'name', 'id');

  return {
    cancelTypeList,
    needStateList,
    checkStateList,
    supplyWayList,
    // supplyList,
    supplyKindList,
    levelList,
    materialTypeList,
    materialTypeMapList,
    mapLoading,
  };
};
